var http=require("http");
var cheerio=require('cheerio');
var url="http://pvp.qq.com/web201605/herodetail/121.shtml"
function trim(str,is_global)
        {
            var result;
            result = str.replace(/(^\s+)|(\s+$)/g,"");
            if(is_global.toLowerCase()=="g")
            {
                result = result.replace(/\s/g,"");
             }
            return result;
}
function filter(html){
	var $=cheerio.load(html)
	var heroData=$('.pic-show-box')
	
	return heroData
}

function printHeroInfo(heroData){
	console.log(heroData)
	// herosData.forEach(function(item){
	// 	var heroName=item.heroName
	// 	console.log(heroName+'\n')
	// 	// item.pics.forEach(function(video) {
	// 	// 	console.log('['+video.id+']'+video.title+'\n')
	// 	// })
	// })
}
http.get(url,function(res){
	var html=''
	res.on('data',function(data){
		html+=data;
	})
	res.on("end",function(){
		// console.log(html)
		var heroData=filter(html)
		printHeroInfo(heroData);
	})
}).on('error',function(){
	console.log('获取数据失败');
})